"use strict";
cc._RF.push(module, 'bdc91QO3ddAt5nQfZr9K2G3', 'btButton');
// scripts/O1ModuleRes/control/btButton.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BT_BODY_COLOR = exports.BT_LINE_COLOR = void 0;
/**
 * {class} 框架按钮
 */
var executeInEditMode = cc._decorator.executeInEditMode;
var playOnFocus = cc._decorator.playOnFocus;
var gameEngine_1 = require("../../engines/gameEngine");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property, requireComponent = _a.requireComponent;
//描边颜色
var BT_LINE_COLOR;
(function (BT_LINE_COLOR) {
    BT_LINE_COLOR[BT_LINE_COLOR["WHITE"] = 0] = "WHITE";
    BT_LINE_COLOR[BT_LINE_COLOR["BLACK"] = 1] = "BLACK";
})(BT_LINE_COLOR = exports.BT_LINE_COLOR || (exports.BT_LINE_COLOR = {}));
var BT_BODY_COLOR;
(function (BT_BODY_COLOR) {
    BT_BODY_COLOR[BT_BODY_COLOR["NORMAL"] = 0] = "NORMAL";
    BT_BODY_COLOR[BT_BODY_COLOR["OUTSTANDING"] = 1] = "OUTSTANDING";
    BT_BODY_COLOR[BT_BODY_COLOR["OBVIOUS"] = 2] = "OBVIOUS";
})(BT_BODY_COLOR = exports.BT_BODY_COLOR || (exports.BT_BODY_COLOR = {}));
var btButton = /** @class */ (function (_super) {
    __extends(btButton, _super);
    function btButton() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.lineColor = BT_LINE_COLOR.WHITE;
        _this.bodyColor = BT_BODY_COLOR.NORMAL;
        _this.textColor = BT_LINE_COLOR.WHITE;
        _this.strButton = '按钮事件';
        return _this;
    }
    btButton.prototype.onLoad = function () {
        this.OnUpdateLineColor();
        this.OnUpdateBodyColor();
        this.OnUpdateTextColor();
        this.node.on('click', function () {
            gameEngine_1.managers().soundMgr.playSound('mainSound/anNiu').then();
            gameEngine_1.managers().soundMgr.playVibrate();
        });
    };
    btButton.prototype.start = function () {
    };
    btButton.prototype.getButtonText = function () {
        return this.strButton;
    };
    btButton.prototype.setButtonText = function (text) {
        this.strButton = text;
        var bgNode = this.node.getChildByName('Background');
        if (bgNode) {
            var lbLabel = bgNode.getChildByName('Label');
            if (lbLabel) {
                lbLabel.getComponent(cc.Label).string = this.strButton;
            }
        }
    };
    btButton.prototype.OnUpdateLineColor = function () {
        switch (this.lineColor) {
            case BT_LINE_COLOR.WHITE: {
                this.node.color = cc.Color.WHITE;
                break;
            }
            case BT_LINE_COLOR.BLACK: {
                this.node.color = cc.Color.BLACK;
                break;
            }
        }
    };
    btButton.prototype.OnUpdateBodyColor = function () {
        var bgNode = this.node.getChildByName('Background');
        if (!bgNode) {
            console.error('#57错误 不存在的背景节点');
            return;
        }
        switch (this.bodyColor) {
            case BT_BODY_COLOR.NORMAL: {
                bgNode.color = cc.color(140, 208, 255);
                break;
            }
            case BT_BODY_COLOR.OUTSTANDING: {
                bgNode.color = cc.color(255, 211, 48);
                break;
            }
            case BT_BODY_COLOR.OBVIOUS: {
                bgNode.color = cc.color(230, 100, 76);
                break;
            }
        }
        var lbLabel = bgNode.getChildByName('Label');
        if (!lbLabel) {
            return;
        }
        lbLabel.getComponent(cc.Label).string = this.strButton;
    };
    btButton.prototype.OnUpdateTextColor = function () {
        var lbTextNode = cc.find('Background/Label', this.node);
        switch (this.textColor) {
            case BT_LINE_COLOR.WHITE: {
                lbTextNode.color = cc.Color.WHITE;
                break;
            }
            case BT_LINE_COLOR.BLACK: {
                lbTextNode.color = cc.Color.BLACK;
                break;
            }
        }
    };
    btButton.prototype.update = function (dt) {
        if (CC_EDITOR) {
            this.OnUpdateLineColor();
            this.OnUpdateBodyColor();
            this.OnUpdateTextColor();
        }
    };
    __decorate([
        property({ type: cc.Enum(BT_LINE_COLOR), displayName: '按钮描边色', tooltip: '固定黑白' }) //
    ], btButton.prototype, "lineColor", void 0);
    __decorate([
        property({ type: cc.Enum(BT_BODY_COLOR), displayName: '按钮颜色', tooltip: 'NORMAL(普通按钮)\nOUTSTANDING(突出按钮)\nOBVIOUS(更突出、明显按钮)' }) //
    ], btButton.prototype, "bodyColor", void 0);
    __decorate([
        property({ type: cc.Enum(BT_LINE_COLOR), displayName: '按钮文本颜色', tooltip: '固定黑白' }) //
    ], btButton.prototype, "textColor", void 0);
    __decorate([
        property({ displayName: '按钮文本', multiline: true })
    ], btButton.prototype, "strButton", void 0);
    btButton = __decorate([
        ccclass,
        requireComponent(cc.Button),
        executeInEditMode(),
        playOnFocus()
    ], btButton);
    return btButton;
}(cc.Component));
exports.default = btButton;

cc._RF.pop();